Include filename in path fingerprint
authorAlex Crichton <alex@alexcrichton.com>
Fri, 9 Oct 2015 04:30:33 +0000 (21:30 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 9 Oct 2015 04:30:33 +0000 (21:30 -0700)
This helps diagnose "why did this rebuild" situations so not only the mtime is
known but also the file in question.

src/cargo/sources/path.rs

index 60915a881de18140245a9fccf0a5c468d943e9e2..1da040f1a1be1e4b4341f953e06f84735316371e 100644 (file)
@@ -1,4 +1,3 @@
-use std::cmp;
 use std::fmt::{self, Debug, Formatter};
 use std::fs;
 use std::io::prelude::*;
@@ -313,19 +312,23 @@ impl<'cfg> Source for PathSource<'cfg> {
         }
 
         let mut max = FileTime::zero();
-        for file in try!(self.list_files(pkg)).iter() {
+        let mut max_path = PathBuf::from("");
+        for file in try!(self.list_files(pkg)) {
             // An fs::stat error here is either because path is a
             // broken symlink, a permissions error, or a race
             // condition where this path was rm'ed - either way,
             // we can ignore the error and treat the path's mtime
             // as 0.
-            let mtime = fs::metadata(file).map(|meta| {
+            let mtime = fs::metadata(&file).map(|meta| {
                 FileTime::from_last_modification_time(&meta)
             }).unwrap_or(FileTime::zero());
             warn!("{} {}", mtime, file.display());
-            max = cmp::max(max, mtime);
+            if mtime > max {
+                max = mtime;
+                max_path = file;
+            }
         }
         trace!("fingerprint {}: {}", self.path.display(), max);
-        Ok(max.to_string())
+        Ok(format!("{} ({})", max, max_path.display()))
     }
 }